class SignupController < ApplicationController
 layout "signup"
 def index 
 end
 def create_account
	 @admin = User.create(params[:user])
	 @company = Company.create(params[:company])
	 @company.plan = Plan.find(params[:plan])
	 @admin.company_id = @company.id
	 @admin.save
	 if @admin.save
	  @company.owner_id = @admin.id
	  @company.save
          Notifier.deliver_notify('signup',@admin.email,@admin,@admin.lang) if @admin.email.match("@")
		 flash[:notice] = "company saved!"
		 redirect_to  :action=>"success",:company=>@company.id
	 end
 end
 def check_url
    @url = params[:url]
	if Company.find(:first,:conditions=>["url = ?",@url])
	render :partial=>'taken'
	else
	render :partial=>'avaliable'
	end
 end
 def set_password
    session[:password] = params[:password]
	if session[:password_c].to_s != session[:password].to_s
	  render_text '<strong>' + 'password not match!'.t + '</strong>'
	else
	render :nothing => true
	end
 end
 def check_password
    session[:password_c] = params[:password_c]
	if session[:password_c].to_s != session[:password].to_s
	  render_text '<strong>' + 'password not match!'.t + '</strong>'
	else
	  render :nothing=>true
	end
 end
 def success
   @company = Company.find(params[:company])
 end
end
